<?php
require_once 'classes/authorization.class.php';

$user  		= $_POST['username'];
$password	= $_POST['password'];
$ext		= $_POST['ext'];
$login 		= new Authorization();
$login->set_ext($ext);
$login->set_username($user);
$login->set_password($password);

$check = $login->checklogin();

if ($check) {
	$login->ip();
	$login->savelogin();
	$login->expire(36000);
	echo '<meta http-equiv=refresh content="0; URL=index.php">';

}else {

	?>
		<html>
			<head>
				<meta charset="utf-8">
				<title>ავტორიზაცია</title>
				<link rel="stylesheet" type="text/css" href="media/css/login/style.css" />
			</head>
			<body>
				<div class="container">
					<section id="content">
						<form action="" method="post">
							<h1>ავტორიზაცია</h1>
							<div>
								<input name="username" type="text" placeholder="მომხმარებელი" required="" id="username" autocomplete="off"/>
							</div>
							<div>
								<input name="password" type="password" placeholder="პაროლი" required="" id="password" autocomplete="off"/>
							</div>
							<!--div>
								<select name="ext" id="ext" >
										<option value="0">----</option>
										<option value="Call Center 1">Call Center 1</option>
            							<option value="Call Center 2">Call Center 2</option>
            							<option value="Call Center 3">Call Center 3</option>
            							<option value="Call Center 4">Call Center 4</option>            							
            							<option value="Confidencial">Confidencial</option>
            							<option value="Gazifikacia">Gazifikacia</option>
            							<option value="Kancelaria">Kancelaria</option>
            							<option value="Sadispechero">Sadispechero</option>            							
            							<option value="Combit">Combit</option>
            							<option value="Samgori Op">Samgori Op</option>
            							<option value="Samgori tex">Samgori tex</option>
            							<option value="Isani Op">Isani Op</option>            							
            							<option value="Isani Tex">Isani Tex</option>
            							<option value="Didube Op">Didube Op</option>							
            							<option value="Didube Tex">Didube Tex</option>
            							<option value="Sanzona Op">Sanzona Op</option>
            							<option value="Sanzona Tex">Sanzona Tex</option>            							
            							<option value="Gldani Op">Gldani Op</option>
            							<option value="Nadzaladevi Op">Nadzaladevi Op</option>
            							<option value="Nadzaladevi Tex">Nadzaladevi Tex</option>
            							<option value="Gldani Tex">Gldani Tex</option>
            							<option value="Saburtalo Op">Saburtalo Op</option>            							
            							<option value="Saburtalo Tex">Saburtalo Tex</option>
            							<option value="Nutsubidze Op">Nutsubidze Op</option>
            							<option value="Nutsubidze Tex">Nutsubidze Tex</option>
            							<option value="Vake Op">Vake Op</option>            							
            							<option value="Vake Tex">Vake Tex</option>
            							<option value="Mtatsminda Op">Mtatsminda Op</option>
            							<option value="Mtatsminda Tex">Mtatsminda Tex</option>
            							<option value="Digomi Op">Digomi Op</option>            							
            							<option value="Digomi Tex">Digomi Tex</option>
            							<option value="IT Irakli">IT Irakli</option>
								</select>
							</div-->
							<div>
								<input type="submit" value="შესვლა" />
							</div>
						</form>
					</section>
				</div>
			</body>
		</html>

<?php }

